
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../event/scan_event.dart';
import '../../main.dart';

class ScanModel{

  show({int width = 510,int marginLeft = 10}){
    tts.speak('请放置图书');
    return Container(
      margin: EdgeInsets.only(left: marginLeft.w),
      padding: EdgeInsets.all(30.r),
      width: width.w,
      height: 310.h,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(4.r)),
      ),
      alignment: Alignment.center,
      child: Column(
        children: [
          Text("放置图书",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
          SizedBox(height: 10.h,),
          Stack(
            alignment: AlignmentDirectional.center,
            children: [
              Image.asset("assets/images/mode.png",width:310.w,fit: BoxFit.fitWidth,),
              Positioned(
                top: 50.h,
                right: 0,
                child: Image.asset("assets/images/book.png",width:70.w,fit: BoxFit.fitWidth,),
              )
            ],
          ),
          SizedBox(height: 10.h,),
          _scanWidget()
        ],
      ),
    );
  }

  _scanWidget(){
    return Container(
        width: 300.w,
        decoration: BoxDecoration(
          color: const Color.fromRGBO(239, 244, 255, 1),
          borderRadius: BorderRadius.all(Radius.circular(16.r)),
        ),
        padding: EdgeInsets.only(left:10.r),
        margin: EdgeInsets.only(bottom: 10.r),
        child: Row(
          children: [
            Image.asset("assets/images/scan.png",width:20.w,fit: BoxFit.fitWidth,),
            SizedBox(
              width: 220.w,
              child: TextField(
                minLines: 1,
                textInputAction: TextInputAction.done,
                decoration: InputDecoration(
                    contentPadding: EdgeInsets.only(top: 8.r,bottom: 8.r),
                    isCollapsed: true,
                    hintText: "可扫描图书条形码进行借书",
                    border: InputBorder.none,
                    hintStyle: TextStyle(color: Colors.blue,fontSize: 8.sp)
                ),
                style: TextStyle(color: Colors.blue,fontSize: 8.sp),
                onSubmitted: (value) {
                  eventFactory.fire(ScanEvent(value));
                },
              ),

            ),
          ],
        )
    );
  }

}

